<template>
	<view class="cover-page">
		<u-loading mode="flower" :show="!isSuccess" color="red" size="100" class="my-loading"></u-loading>
	</view>
</template>

<script>
  import configdata from '@/common/config.js'
	export default {
		data() {
			return {
				configdata,
				testApi:[
				  "https://www.qqiuanvip1.com/1.json",
				  "https://www.qqiuan.com",
				  "https://www.qqiuanvip2.com/1.json",
				  "https://admin.shklive.net/index/index/appDownUrl",
				  "https://www.qqiuanvip4.com/1.json",
				  "https://www.qqiuanvip5.com/1.json",
				  "https://www.qqiuanvip6.com/1.json",
				  "https://www.qqiuanvip7.com/1.json",
				  "https://www.qqiuanvip8.com/1.json",
				  "https://www.qqiuanvip9.com/1.json",
				],
				ROOTPATHLIST:[
				  "https://www.qqiuanvip1.com/",
				  "https://www.qqiuan.com/",
				  "https://www.qqiuanvip2.com/",
				  "https://admin.shklive.net/index/",
				  "https://www.qqiuanvip4.com/",
				  "https://www.qqiuanvip5.com/",
				  "https://www.qqiuanvip6.com/",
				  "https://www.qqiuanvip7.com/",
				  "https://www.qqiuanvip8.com/",
				  "https://www.qqiuanvip9.com/",
				],
        TESTPATHINDEX: 0,
        isSuccess: false,
			};
		},
    onLoad() {
      this.testRouter(this.testApi[0])
    },
    methods:{
      testRouter(testPath) {
        if(this.TESTPATHINDEX > 9){
          this.TESTPATHINDEX = 0
        }
        uni.request({
          url: testPath,
          success: (result)=>{
          	configdata.APIHOST = this.ROOTPATHLIST[this.TESTPATHINDEX]
            console.log(this.ROOTPATHLIST[this.TESTPATHINDEX], 'success')
            this.isSuccess = true
            uni.switchTab({
              url: '/pages/index/index'
            })
          },
          fail: (e)=>{
            console.log(this.ROOTPATHLIST[this.TESTPATHINDEX],'fail')
            this.isSuccess = false
            this.TESTPATHINDEX += 1
            this.testRouter(this.testApi[this.TESTPATHINDEX])
          }
        })
      }
    }
	}
</script>

<style lang="scss" scoped>
  .cover-page{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    background-color: #FFFFFF;
    .my-loading{
      position: absolute;
      left: 44%;
      top: 100rpx;
    }
  }
</style>
